package com.qc.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qc.common.Session;
import com.qc.entity.SystemMessageEntity;
import com.qc.service.SystemMessageService;

import net.sf.json.JSONObject;

@Controller
public class MobileSystemMessageController extends BaseController{

	@Resource(name="systemMessageService")
	private SystemMessageService systemMessageService;
	
	@RequestMapping(value = "/MobileGetAllSytemMessage", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String MobileGetAllSytemMessage(HttpServletRequest request, HttpServletResponse response) {

		String p1 = request.getParameter("p1");
		String p2 = request.getParameter("p2");
		
		long userId = Session.getUserIdfromMobileSession(p2);
		
		SystemMessageEntity entity = (SystemMessageEntity)JSONObject.toBean(JSONObject.fromObject(p1), SystemMessageEntity.class);
		
		List<SystemMessageEntity> list = systemMessageService.listAllSystemMessage(entity.getCreatedTime(), userId);
		
		return returnSuccessResult(list);
	}
}
